refactor: display exact command name for -v option#169
Merged
Conversation
Contributor
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified FilesNo covered modified files...
|
a5a3b3a to
45f6988
Compare
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
45f6988 to
1d850d9
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the version callback function to dynamically retrieve the application name instead of using a hardcoded value. The change replaces the hardcoded "t4viz" string with the current CLI context's application name.
- Imports click module to access current context information
- Replaces hardcoded application name with dynamic context-based name retrieval
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| ctx = click.get_current_context() | ||
| version = importlib.metadata.version("t4-devkit") | ||
| console.print(f"[bold green]t4viz[/bold green]: [cyan]{version}[/cyan]") | ||
| console.print(f"[bold green]{ctx.info_name}[/bold green]: [cyan]{version}[/cyan]") |
There was a problem hiding this comment.
The ctx.info_name attribute may be None in some contexts, which would result in displaying 'None' in the version output. Consider adding a fallback value or null check.
Suggested change
| console.print(f"[bold green]{ctx.info_name}[/bold green]: [cyan]{version}[/cyan]") | |
| info_name = ctx.info_name if ctx.info_name is not None else "t4-devkit" | |
| console.print(f"[bold green]{info_name}[/bold green]: [cyan]{version}[/cyan]") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This PR updates
version_callbackin order to display right command name.